<?=$this->header(true)?>


    <?=$this->menu("events")?>


    <h1><?=$this->message("nav.events")?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("nav.events"),
                "href"=>"event/list"
            ),
            array(
                "name"=>$this->languageRoute(
                            $this->message("label.item", _Event::BUNDLE),              // Item name
                            $this->eventForm->getEventI18n()->getDefaultName(
                                $this->param(_Core::DEFAULT_LANGUAGE)),           // Default language item name
                            $this->eventForm->getEventI18n()->getEventI18nId(), // Id
                            $this->eventForm->getEventI18n()->getLanguage())    // Language


            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Event::BUNDLE)?>


    <form id="<?=get_class($this->eventForm)?>" action="event/save" method="post" enctype="multipart/form-data">

        <div>
            <input type="hidden"
                   name="eventI18n->eventI18nId"
                   value="<?=$this->eventForm->getEventI18n()->getEventI18nId()?>" />
            <input type="hidden"
                   name="eventI18n->eventId"
                   value="<?=$this->eventForm->getEventI18n()->getEventId()?>" />
            <input type="hidden"
                   name="eventI18n->languageCode"
                   value="<?=$this->eventForm->getEventI18n()->getLanguageCode()?>" />

        </div>

        <fieldset>

            <legend><?=$this->message("label.required")?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("eventI18n->name")?>">
                <th><label for="eventI18n_name"><?=$this->message("prompt.name", _Event::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="eventI18n->name"
                           id="eventI18n_name"
                           value="<?=$this->eventForm->getEventI18n()->getName()?>"
                           maxlength="255"
                           type="text"
                           class="textInput" />
                </td>
            </tr>
            <tr class="ctrl<?=$this->error("eventI18n->intro")?>">
                <th><label for="eventI18n_intro"><?=$this->message("prompt.intro", _Event::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <textarea name="eventI18n->intro"
                              id="eventI18n_intro"
                              rows="7" cols="80"><?=!is_null($this->eventForm->getEventI18n()->getIntro()) ?
                                $this->eventForm->getEventI18n()->getIntro()->getContents() : ""?></textarea>
                    <p class="hint"><?=$this->message("note.intro", _Core::BUNDLE)?></p>
                </td>
            </tr>

            <? /* Only show date with default language events */ ?>
            <? if($this->eventForm->getEventI18n()->getLanguageCode() == $this->param(_Core::DEFAULT_LANGUAGE)): ?>

                <tr class="ctrl<?=$this->error("day")?><?=$this->error("month")?><?=$this->error("year")?>">
                    <th><?=$this->message("prompt.date", _Event::BUNDLE)?><p class="hint">(<label for="day"><?=$this->message("prompt.day", _Event::BUNDLE)?></label>/<label for="month"><?=$this->message("prompt.month", _Event::BUNDLE)?></label>/<label for="year"><?=$this->message("prompt.year", _Event::BUNDLE)?></label>)</p></th>
                    <th class="required"><em>*</em></th>
                    <td>
                        <?=$this->formDays(
                            "day",
                            $this->eventForm->getDay()
                        )?>
                        <?=$this->formMonths(
                            "month",
                            $this->eventForm->getMonth()
                        )?>
                        <?=$this->formYears(
                            "year",
                            $this->eventForm->getYear()
                        )?>
                    </td>
                </tr>

            <? endif; ?>
            </table>

        </fieldset>

        <fieldset>

            <legend><?=$this->message("label.optional")?></legend>

            <table cellspacing="0" cellpadding="0" class="form">

            <? /* Only show time with default language events */ ?>
            <? if($this->eventForm->getEventI18n()->getLanguageCode() == $this->param(_Core::DEFAULT_LANGUAGE)): ?>

                <tr class="ctrl<?=$this->error("eventI18n->time")?>">
                    <th><?=$this->message("label.time", _Event::BUNDLE)?><p class="hint">(<label for="hour"><?=$this->message("prompt.hour", _Event::BUNDLE)?></label>:<label for="minute"><?=$this->message("prompt.minute", _Event::BUNDLE)?></label>)</p></th>
                    <th class="required"><em>&nbsp;</em></th>
                    <td>
                        <?=$this->formHours(
                            "hour",
                            $this->eventForm->getHour()
                        )?>
                        <?=$this->formMinutes(
                            "minute",
                            $this->eventForm->getMinute()
                        )?>
                    </td>
                </tr>

            <? endif; ?>

            <tr class="ctrl<?=$this->error("eventI18n->description")?>">
                <th><label for="eventI18n_description"><?=$this->message("prompt.description", _Event::BUNDLE)?></label></th>
                <th class="required"><em>&nbsp;</em></th>
                <td>
                    <textarea id="eventI18n_description"
                              name="eventI18n->description"
                              mce_editable="true"
                              rows="20"
                              cols="70"><?=!is_null($this->eventForm->getEventI18n()->getDescription()) ?
                                            $this->eventForm->getEventI18n()->getDescription()->getContents() : ""?></textarea>
                    <p class="hint"><?=$this->message("note.image", _Core::BUNDLE, null, null, false)?></p>
                </td>
            </tr>

            <? /* Only show url with default language events */ ?>
            <? if($this->eventForm->getEventI18n()->getLanguageCode() == $this->param(_Core::DEFAULT_LANGUAGE)): ?>

                <tr class="ctrl<?=$this->error("eventI18n->event->url")?>">
                    <th><label for="eventI18n_event_url"><?=$this->message("prompt.url", _Event::BUNDLE)?></label></th>
                    <th class="required"><em></em></th>
                    <td>
                        <input name="eventI18n->event->url"
                               id="eventI18n_event_url"
                               value="<?=$this->eventForm->getEventI18n()->getEvent()->getUrl()?>"
                               maxlength="255"
                               type="text"
                               class="textInput" />
                        <p class="hint"><?=$this->message("note.url", _Core::BUNDLE)?></p>
                    </td>
                </tr>
                <tr class="ctrl<?=$this->error("formImage")?>">
                    <th><label for="formImage"><?=$this->message("label.image", _Core::BUNDLE)?></label></th>
                    <th class="required"><em>&nbsp;</em></th>
                    <td>
                        <? if(!is_null($this->eventForm->getEventI18n()->getEvent()) &&
                            $this->eventForm->getEventI18n()->getEvent()->getImageId() > 0 &&
                            !is_null($this->eventForm->getEventI18n()->getEvent()->getImageRelatedByImageId())) { ?>

                            <input type="hidden"
                                   name="eventI18n->event->imageRelatedByImageId->imageId"
                                   value="<?=$this->eventForm->getEventI18n()->getEvent()->getImageId()?>" />
                            <input type="hidden"
                                   name="eventI18n->event->imageRelatedByThumbnailId->imageId"
                                   value="<?=$this->eventForm->getEventI18n()->getEvent()->getThumbnailId()?>" />

                            <input type="hidden"
                                   name="eventI18n->event->imageRelatedByImageId->binaryFileId"
                                   value="<?=$this->eventForm->getEventI18n()->getEvent()->getImageRelatedByImageId()->getBinaryFileId()?>" />
                            <input type="hidden"
                                   name="eventI18n->event->imageRelatedByThumbnailId->binaryFileId"
                                   value="<?=$this->eventForm->getEventI18n()->getEvent()->getImageRelatedByThumbnailId()->getBinaryFileId()?>" />

                            <img src="image?id=<?=$this->eventForm->getEventI18n()->getEvent()->getImageId()?>"
                                 width="<?=$this->eventForm->getEventI18n()->getEvent()->getImageRelatedByImageId()->getWidth()?>"
                                 height="<?=$this->eventForm->getEventI18n()->getEvent()->getImageRelatedByImageId()->getHeight()?>" alt="" />

                            <input type="checkbox" name="deleteImage" value="true" id="deleteImage" /> <label for="deleteImage"><?=$this->message("label.image.delete", _Core::BUNDLE)?></label>

                            <br /><br />

                        <? } ?>

                        <input type="file" name="formImage" />

                        <p class="hint"><?=$this->message("note.image.resize", _Core::BUNDLE)?> <?=$this->imageProps($this->param(_Core::SETTING_LIST))->getImageWidth()?>x<?=$this->imageProps($this->param(_CORE::SETTING_LIST))->getImageHeight()?>.</p>

                    </td>
                </tr>

            <? endif; ?>
            </table>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('event/list')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>

<?=$this->footer()?>